﻿using System;
using System.Windows;

namespace WebsiteLoadTool.Configuration
{
    public partial class ConfigurationWindowView : Window
    {
        public ConfigurationWindowView()
        {
            InitializeComponent();

            if (DataContext is ConfigurationWindowViewModel)
                ((ConfigurationWindowViewModel)DataContext).OnOK += OnOK;
        }

        private void OnOK(object sender, EventArgs e)
        {
            DialogResult = true;
            Close();
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);

            if (DataContext is ConfigurationWindowViewModel)
                ((ConfigurationWindowViewModel)DataContext).OnOK -= OnOK;
        }
    }
}
